import { $http } from './index';

// 获取楼盘列表
export const getBuildingList = (params) => {
    return $http.post('/saas/premises/queryPremises', params);
};

// 获取楼盘图数据
export const getBuildingOrgTreeData = (params) => {
    return $http.post('/saas/premises/queryPremisesPointMap', params);
};

// 新建楼栋
export const addBuilding = (params) => {
    return $http.post('/saas/build/add', params);
};

// 修改楼栋名称
export const updateBuildingName = (params) => {
    return $http.put(`/saas/build/updateName?buildId=${ params.buildId }&name=${ params.name }`);
};

// 删除楼栋
export const deleteBuilding = (params) => {
    return $http.delete(`/saas/build/deleteBuild/${ params.buildId }`);
};

// 新建单元
export const addUnit = (params) => {
    return $http.post('/saas/unit/add', params);
};

// 修改单元名称
export const updateUnitName = (params) => {
    return $http.put(`/saas/unit/updateName?unitId=${ params.unitId }&name=${ params.name }`);
};

// 删除单元
export const deleteUnit = (params) => {
    return $http.delete(`/saas/unit/deleteUnit/${ params.unitId }`);
};

// 新建电梯
export const addElevator = (params) => {
    return $http.post('/saas/elevator/add', params);
};

// 修改电梯
export const updateElevator = (params) => {
    const url = `/saas/elevator/updateName?elevatorId=${ params.elevatorId }&eleType=${ params.eleType }&eleNum=${ params.eleNum }&name=${ params.name }`;
    return $http.put(url);
};

// 删除电梯
export const deleteElevator = (params) => {
    return $http.delete(`/saas/elevator/deleteElevator/${ params.elevatorId }`);
};

// 新建楼层
export const addFloor = (params) => {
    return $http.post('/saas/floor/add', params);
};

// 修改楼层名称
export const updateFloorName = (params) => {
    return $http.put(`/saas/floor/updateName?floorId=${ params.floorId }&name=${ params.name }`);
};

// 删除楼层
export const deleteFloor = (params) => {
    return $http.delete(`/saas/floor/deleteFloor/${ params.floorId }`);
};

// 新建出入门
export const addGate = (params) => {
    return $http.post('/saas/gate/addGate', params);
};

// 修改出入门名称
export const updateGateName = (params) => {
    return $http.put(`/saas/gate/updateGateName?gateId=${ params.gateId }&name=${ params.name }`);
};

// 删除出入门
export const deleteGate = (params) => {
    return $http.delete(`/saas/gate/deleteGate/${ params.gateId }`);
};

// 新建道闸/门禁
export const addGateway = (params) => {
    return $http.post('/saas/gateway/addGateway', params);
};

// 修改道闸/门禁
export const updateGateway = (params) => {
    return $http.put('/saas/gateway/updateGatewayName', params);
};

// 删除道闸/门禁
export const deleteGateway = (params) => {
    return $http.delete(`/saas/gateway/deleteGateway/${ params.gatewayId }`);
};

export default {
    getBuildingList,
    getBuildingOrgTreeData,
    addBuilding,
    updateBuildingName,
    deleteBuilding,
    addUnit,
    updateUnitName,
    deleteUnit,
    addElevator,
    updateElevator,
    deleteElevator,
    addFloor,
    updateFloorName,
    deleteFloor,
    addGate,
    updateGateName,
    deleteGate,
    addGateway,
    updateGateway,
    deleteGateway,
};
